package main

import (
	"context"
	"log"

	grpc_trace "github.com/aoliang/go2sky-plugins/grpc"
	"google.golang.org/grpc"

	pb "gitee.com/aoliang/trace/skywalking/grpc/proto"
)

func main() {
	traceInterceptor := grpc_trace.NewUnaryClientTraceInterceptor(getTracer("user"))
	conn, err := grpc.Dial("localhost:50051", grpc.WithInsecure(), grpc.WithUnaryInterceptor(traceInterceptor))
	if err != nil {
		log.Fatalf("did not connect: %v", err)
	}
	defer conn.Close()
	c := pb.NewGreeterClient(conn)

	r, err := c.SayHello(context.Background(), &pb.HelloRequest{Name: "yoyoyo"})
	if err != nil {
		log.Fatalf("could not greet: %v", err)
	}
	log.Printf("Greeting: %s", r.Message)
}
